#!/bin/bash
cd ~/app-root/data/temp/Nexus4
url=$(curl -s https://github.com/opengapps/arm64/releases/ | grep -o 'opengapps/arm64/releases/download/[0-9]\{8\}/open_gapps-arm64-6.0-pico-[0-9]\{8\}\.zip' |sed '2,$d')
if ! grep -q "$url" gapps6url; then
echo $url > gapps6url
wget --no-check-certificate https://github.com/$(cat gapps6url) --output-document=gapps.zip
zip gapps.zip -d GApps\/* Optional\/* Core/configupdater* Core/googlefeedback* Core/googleonetimeinitializer* Core/googlepartnersetup* Core/setupwizardtablet*
unzip -o gapps.zip installer.sh
sed -i '/Install\/Remove SwypeLibs/a\rm -f /system/recovery\* /system/media/audio/ui/camera\* /system/media/audio/ui/Video\*\ncp -rf /sdcard/SpeedSoftware/Extracted/6.0/app/\* /system/app/\nsed -i \"/gChannelBondingMode24GHz/s#0#1#\" /system/etc/wifi/*_cfg.ini' installer.sh
zip -u gapps.zip installer.sh
mv -f gapps.zip $(grep -o "open_gapps-arm64.*zip" gapps6url)
~/app-root/data/github-sh/Nexus4/openload_uploader.sh upload "$(ls /var/lib/openshift/53eafa98e0b8cdd9f1000005/app-root/data/temp/Nexus4/open_gapps-arm64*.zip)" "OnePlus3T"
rm -f installer.sh ~/app-root/data/temp/Nexus4/open_gapps-arm64*.zip
fi
